#ifndef Calque_H
#define Calque_H

#include <QtGui>
#include <iostream>
#include <vector>

class Calque : public QImage
{

public:
    explicit Calque(int posX = 0, int posY = 0);
    explicit Calque(int width, int height, Format format, int posX = 0, int posY = 0, int opacite = 100);
    explicit Calque(const QString & fileName, const char * format = 0, int posX = 0, int posY = 0);
    explicit Calque(const Calque & image, int posX = 0, int posY = 0);
    explicit Calque(const char * fileName, const char * format = 0, int posX = 0, int posY = 0);
    explicit Calque(QImage image, int posX = 0, int posY = 0);
    ~Calque();

    void iniInfo();
    void updateInfo();
    std::vector<std::vector<int> >* getHistogrammeRgb() ;
    std::vector<std::vector<double> >* getHistogrammeYuv() ;

    void setPosition(int x = 0, int y = 0);
    void setNom(QString n);
    void setVisible(bool b);
    void setOpacite(int o);

    bool isVisible();


    int getOpacite();
    int getPosX();
    int getPosY();
    QString* getNom();
    void egaliserHistogramme();
    void recadrageHistogramme(int destMin, int destMax);
    static int recadrage(double A, double B, double C, double D, double val);

    Calque * copie();

    int i;
    int j;
private:
    static const int rouge=0;
    static const int vert=1;
    static const int bleu=2;
    static const int Y=0;
    static const int U=1;
    static const int V=2;

    double rgbToY(QRgb rgb);
    double rgbToU(QRgb rgb);
    double rgbToV(QRgb rgb);
    QRgb yuvToRgb(double y, double u, double v);
    std::vector<std::vector<int> > histogrammeRgb;
    std::vector<std::vector<double> > histogrammeYuv;


    // positions horizontales et verticales
    QString* nom;
    int opacite;
    bool visible;
    int posX;
    int posY;


    void updateHistogramme();
    void razHistogramme();

};

#endif // Calque_H
